package com.qidian.mes.pro.controller;

import com.qidian.mes.pojo.Proces;
import com.qidian.mes.pojo.WorkTicket;
import com.qidian.mes.pro.service.ProcesService;
import com.qidian.mes.util.pojo.MESResult;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.web.bind.annotation.*;

/**
 * @Author chenzheng
 * @Company 起点编程
 * @Time 2023/10/27 19:23
 * @Description
 */
@RestController
@RequestMapping("/process")
@CrossOrigin
public class ProcessController {
    @Autowired
    private ProcesService procesService;
    //工序查询
    @RequestMapping("/get")
    public MESResult get(Long processId){
        MESResult mes = procesService.queryById(processId);
        System.out.println(mes.getData());
        return mes;
    }
    //新增工序
    @PostMapping("/save")
    public MESResult save(@RequestBody Proces proces){
        return procesService.save(proces);
    }
    //编辑工序
    @PutMapping("/update")
    public MESResult update(@RequestBody Proces proces){
        return procesService.update(proces);
    }
    //删除工序
    @DeleteMapping("/delete")
    public MESResult delete(Long processId){
        return procesService.delete(processId);
    }
    @GetMapping("/list")
    public MESResult list(@RequestParam(defaultValue = "1")int page, @RequestParam(defaultValue = "10") int limit, Proces proces){
        return procesService.list(page,limit,proces);
    }
}
